package cn.wicking.mapper.impl;

import cn.wicking.entity.User;
import cn.wicking.mapper.UserMapper;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import java.util.HashMap;
import java.util.List;

/*方式一*/
public class UserMapperWay2Impl extends SqlSessionDaoSupport implements UserMapper {


    public List<User> getUserMessage() {
        final UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        final HashMap<String, Object> map = new HashMap<String, Object>();
        map.put("id",6);
        map.put("username","小三");
        map.put("password","123456");
        mapper.addUser(map);
        mapper.deleteUser(7);
        return mapper.getUserMessage();
    }

    public int addUser(HashMap<String, Object> map) {
        final UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        return mapper.addUser(map);
    }

    public int deleteUser(int id) {
        UserMapper mapper = getSqlSession().getMapper(UserMapper.class);
        return mapper.deleteUser(id);
    }
}
